#include "graph.h"
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N1 = 2e3+10;
int head[N1],cnt,ans[N1],c[N1],siz[N1],dis[N1],v1[N1],cnt1 = 1,o,o1,o2,o3,o4;
map<pair<int,int>,int>mp;
priority_queue<int>p; 
struct w
{
	int to,nxt;
}a[N1];
inline void add(int x,int y)
{
	a[++cnt].nxt = head[x];
	a[cnt].to = y;
	head[x] = cnt;
} 
void bfs(int x)
{
	while(!p.empty())
	{
		int y = p.top();
		for(int i = head[y];i;i = a[i].nxt)
			if(dis[a[i].to] > dis[y]+1) dis[a[i].to] = dis[y]+1,p.push(a[i].to);
		p.pop();
	}
}
void Inspect(int R) 
{
    // Write your code here.
   	o = Color(),o1 = NumberOfRoads();
   	if(o == 1) cnt1++,o = cnt1,c[cnt1] = 1; 
	if(v1[o] == 0) v1[o] = LastRoad();
   	for(int i = 1;i <= o1;i++)
   	{
    	Move(i,o),o2 = LastRoad(),o3 = Color();
    	if(o3 == 1) cnt1++,o3 = cnt1,c[cnt1] = 1;
    	Move(o2,o3),add(o,o3),add(o3,o);
	}
	o4 = o,Move(c[o],o),c[o] = c[o]+1;
    while(1)
    {
	   	o = Color(),o1 = NumberOfRoads();
	   	if(o == 1) cnt1++,o = cnt1,c[cnt1] = 1; 
		if(v1[o] == 0) v1[o] = LastRoad();
	   	for(int i = 1;i <= o1;i++)
	   	{
	    	Move(i,o),o2 = LastRoad(),o3 = Color();
	    	if(o3 == 1) cnt1++,o3 = cnt1,c[cnt1] = 1;
	    	Move(o2,o3),add(o,o3),add(o3,o);
		}
		if(o4 != 0) add(o4,o),add(o,o4);
    	if(c[o] <= o1) o4 = cnt1,Move(c[o],o),c[o] = c[o]+1;
    	else if(v1[o] != -1) Move(v1[o],o);
    	else break;
	}
    for(int i = 2;i <= cnt1;i++) 
	{
		for(int j = 2;j <= cnt1;j++) dis[j] = 1e18;
		dis[i] = 0,p.push(i),bfs(i);
		for(int j = i;j <= cnt1;j++) ans[dis[j]]++;
	}
    cnt1 = 0;
	for(int i = 1;i <= R;i++) Answer(i,ans[i]);
}
